const express = require('express')
const router = express.Router()
const {db} = require('../db/dbutils')

router.get('/list',(req,res)=>{
    db.all('select * from Countries_Population',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/chinagdp',(req,res)=>{
    db.all('select * from chinagdp10years',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/provincialgdp',(req,res)=>{
    db.all('select * from chinaprovincialgdp10year',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/provincialgdp1cy',(req,res)=>{
    db.all('select * from chinaprovincialgdp10year1cy',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/provincialgdp1cy/:year',(req,res)=>{
    db.all('select * from chinaprovincialgdp10year1cy where year=?',[req.params.year],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/provincialgdp2cy',(req,res)=>{
    db.all('select * from chinaprovincialgdp10year2cy',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/provincialgdp2cy/:year',(req,res)=>{
    db.all('select * from chinaprovincialgdp10year2cy where year=?',[req.params.year],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/provincialgdp3cy',(req,res)=>{
    db.all('select * from chinaprovincialgdp10year3cy',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/provincialgdp3cy/:year',(req,res)=>{
    db.all('select * from chinaprovincialgdp10year3cy where year=?',[req.params.year],(err,rows)=>{
        res.send(rows)
    })
})

router.get('/shengshandongmunicipalarea',(req,res)=>{
    db.all('select * from shengshandongmunicipalarea',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp/:year',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year where year=?',[req.params.year],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp1cy',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year1cy',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp1cy/:year',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year1cy where year=?',[req.params.year],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp2cy',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year2cy',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp2cy/:year',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year2cy where year=?',[req.params.year],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp3cy',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year3cy',[],(err,rows)=>{
        res.send(rows)
    })
})
router.get('/shengshandongmunicipalgdp3cy/:year',(req,res)=>{
    db.all('select * from shengshandongmunicipalgdp10year3cy where year=?',[req.params.year],(err,rows)=>{
        res.send(rows)
    })
})

module.exports = router